<template>
	<view class="bankAccount">
		<view class="tip">
			请绑定入驻经营主体名下的银行账户，用于收款。
		</view>
		<view class="form-wrapper">
			<view class="item">
				<view class="label">
					主体类型
				</view>
				<view class="value">
					<text v-if="bankInfo.userType == 1">自然人</text>
					<text v-else-if="bankInfo.userType == 2">企业</text>
					<text v-else-if="bankInfo.userType == 3">个体户/合作社</text>
				</view>
			</view>
			<view class="item">
				<view class="label">
					开户名
				</view>
				<view class="value">
					<input type="text" disabled v-model="form.accountName" maxlength="20" placeholder="请输入开户名"
						class="input">
				</view>
			</view>
			<view class="item">
				<view class="label">
					银行账号
				</view>
				<view class="value">
					<input type="number" disabled v-model="form.account" placeholder="请输入银行账号" class="input">
				</view>
			</view>
			<view class="item">
				<view class="label">
					开户银行
				</view>
				<view class="value">
					<text class="input">{{ form.depositBankName }}</text>
				</view>
			</view>
			<view class="item">
				<view class="label">
					账户类型
				</view>
				<view class="value">
					<text v-if="form.accountType == 1" class="input">个人账户</text>
					<text v-else-if="form.accountType == 2" class="input">对公账户</text>
				</view>
			</view>
			<view class="item">
				<view class="label">
					手机号码
				</view>
				<view class="value">
					{{ form.phone || '-' }}
				</view>
			</view>
		</view>
		<view class="tip-wrapper">
			需要更换收款账号信息，请先解绑原收款账号。
		</view>

		<view class="btn" @click="submit">
			解绑
		</view>

		<!-- <uni-city :show="addressShow" :default="[address.provinceCode,address.cityCode]"
			@change="selectCity"></uni-city> -->
	</view>
</template>

<script>
	// import uniCity from '@/components/wx-uni-city/index.vue'
	import {
		pathToBase64
	} from 'image-tools'

	export default {
		data() {
			return {
				form: {
					account: '',
					accountName: '',
					depositBank: '',
					depositBankName: '',
					accountType: '',
					phone: ''
				},
				subjectType: '',
				bankList: []
			}
		},
		onShow() {
			const info = this.bankInfo.account;
			if (info) {
				this.form = {
					id: info.id,
					account: info.pan,
					accountName: info.accNm,
					depositBank: info.panNum,
					depositBankName: info.panBank,
					accountType: info.accType,
					phone: info.bankPhone
				}
			}
		},
		computed: {
			bankInfo() {
				return this.$store.state.bankInfo
			},
		},
		methods: {
			async submit() {
				uni.showModal({
					title: '解绑提示',
					content: '您确定要解绑当前收款账号吗？',
					success: async (e) => {
						if (e.confirm) {
							const data = await this.$api.post('/app/citicbank-account/unbind', this
								.bankInfo.account)
							if (data.code !== 200) {
								uni.showModal({
									title: '银行提示',
									content: data.msg,
									showCancel: false
								})
							} else {
								this.$store.commit('setUserInfo')
								uni.navigateBack()
							}
						}
					}
				})
			}
		},
		components: {
			//uniCity
		}
	}
</script>

<style lang="scss" scoped>
	.bankAccount {
		.tip {
			height: 60upx;
			line-height: 60upx;
			background-color: #ffffff;
			color: #FF8D1A;
			padding: 0 20upx;
			font-size: 28upx;
			margin-top: 1upx;
		}

		.form-wrapper {
			margin: 20upx 20upx;
			border-radius: 20upx;
			background-color: #ffffff;

			.item {
				min-height: 108upx;
				display: flex;
				align-items: center;
				padding: 0 20upx;
				border-top: 2upx solid #efefef;

				&:first-child {
					border-top: 0upx solid #efefef;
				}

				.label {
					color: #222222;
					font-size: 32upx;
				}

				.value {
					flex: 1;
					display: flex;
					align-items: center;
					justify-content: flex-end;

					.input {
						padding-left: 40upx;
						width: 100%;
						text-align: right;
					}

					.textarea {
						width: 500upx;
						height: 70upx;
						margin: 20upx 0;
						text-align: right;
					}

					.placeholder {
						color: #7F7F7F;
					}

					.checkbox-item {
						display: flex;
						align-items: center;
						margin-left: 40upx;
					}
				}
			}
		}

		.bank-popup-wrapper {
			min-height: 900upx;
			background-color: #ffffff;
			border-radius: 20upx 20upx 0 0;
			position: relative;
			bottom: calc(0upx - env(safe-area-inset-bottom));

			.title-wrapper {
				height: 88upx;
				background-color: #f5f5f5;
				display: flex;
				align-items: center;
				padding: 0 32upx;
				border-radius: 20upx 20upx 0 0;
				justify-content: space-between;
			}

			.item {
				height: 88upx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 32upx;
				border-bottom: 2upx solid #efefef;

				.label {
					color: #666666;
				}

				.value {
					color: #343434;
				}
			}
		}

		.tip-wrapper {
			font-size: 28upx;
			margin: 30rpx;
			color: #777777;
		}

		.btn {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 100%;
			height: 98upx;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #ffffff;
			background-color: #F26022;
			transition: .1s linear;

			&:active {
				background-color: #F26022DC;
			}
		}
	}
</style>